package com.app.bimo.library_db;


import com.bytedance.sdk.openadsdk.TTNativeExpressAd;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Transient;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

@Entity
public class BookData {
    /**
     * 书本
     * <p>
     * 1、未读过： lastReadTime=0 ，
     * <p>
     * 2、更新了 x（updateChapterNum）章： lastReadTime>0和updateChapterNum>0 ，
     * <p>
     * 3、当前第 y（lastChapterNumber）章： lastReadTime>0和updateChapterNum=0
     * <p>
     * 4、已完结 ：isComplete=1
     * <p>
     * 5、暂无更新：isComplete=0和updateChapterNum=0
     */
    @Id
    private String novelid;
    private String cover;
    private String novelName;
    private String authorName;
    private String authorid;
    private String rankInfo;
    //免费类型
    private int promotionType;
    private int isComplete;
    private String lastChapterTitle;
    private String lastChapterName;
    private String summary;
    private String lastChapterid;
    @Transient
    private String tips;
    @Transient
    private String chapterTitle;
    @Transient
    private String chapterid;
    private int isRecommend;//	是否系统推荐。1是，0否

    private int lastChapterNumber;
    /**
     * 阅读进度
     * <p>
     * 返回未转换的结果，如返回 0.07，表示7%
     */
    private String readSchedule;
    private int updateChapterNum;
    private String lastReadTime = "0";
    @Convert(columnType = String.class, converter = BookClassDataConvert.class)
    private List<BookClassData> categoryNames;
    //是否vip免费阅读 1 是，0 否
    private int isVip;
    @Transient
    private TTNativeExpressAd ad;

    /**
     * 加入书架的用户id
     */
    private String uuid;
    /**
     * 是否在书架
     * 1在书架  0不在书架
     */
    private int inBookself;
    /**
     * 是否在我的下载
     * 1在  0不再
     */
    private int inDownLoad;
    /**
     * 是否在阅读记录
     * 1在  0不再
     */
    private int inReadRecord;

    /**
     * 模块相关数据
     *
     * @param novelid
     */
    @Transient
    private String moduleName;
    @Transient
    private String moduleid;
    /**
     * description为空字符串  代表更多  可点击  否则不可点击
     */
    @Transient
    private String description;

    /**
     * 1 双排横三
     * 2 竖一双排横二、
     * 3 横三双排横二、
     * 4 竖三、
     * 5 竖三横二
     */
    @Transient
    private int showType;


    /**
     * 是否展示“更多”按钮
     * 1展示
     * 0不展示
     */
    @Transient
    private int isShowMore;
    /**
     * 促销活动
     * <p>
     * 1限免
     * 2全免
     */
    @Transient
    private int modulePromotionType;
    @Convert(columnType = String.class, converter = BookExtDataConvert.class)
    private BookExtData ext;

    //1代表占用1/3  2代表占用一整列 3代表占用 1/2
    @Transient
    private int mType;

    /*作者书单才有的属性start*/
    @Transient
    private String hotInfo;
    @Transient
    private String collectInfo;
    @Transient
    private String readInfo;
    /*作者书单才有的属性end*/


    private long orderTime;

    public BookData(String novelid, int mType) {
        this.novelid = novelid;
        this.mType = mType;
    }

    /**
     * 模块
     *
     * @param novelid
     * @param moduleid
     * @param moduleName
     * @param description
     * @param showType
     * @param promotionType
     * @param ext
     * @param isShowMore
     */

    public BookData(String novelid, String moduleid, String moduleName, String description, int showType, int promotionType, BookExtData ext, int isShowMore) {
        this.novelid = novelid;
        this.moduleid = moduleid;
        this.moduleName = moduleName;
        this.description = description;
        this.showType = showType;
        this.modulePromotionType = promotionType;
        this.ext = ext;
        this.isShowMore = isShowMore;
    }

    @Generated(hash = 911891477)
    public BookData(String novelid, String cover, String novelName, String authorName, String authorid, String rankInfo, int promotionType, int isComplete,
                    String lastChapterTitle, String lastChapterName, String summary, String lastChapterid, int isRecommend, int lastChapterNumber, String readSchedule,
                    int updateChapterNum, String lastReadTime, List<BookClassData> categoryNames, int isVip, String uuid, int inBookself, int inDownLoad, int inReadRecord,
                    BookExtData ext, long orderTime) {
        this.novelid = novelid;
        this.cover = cover;
        this.novelName = novelName;
        this.authorName = authorName;
        this.authorid = authorid;
        this.rankInfo = rankInfo;
        this.promotionType = promotionType;
        this.isComplete = isComplete;
        this.lastChapterTitle = lastChapterTitle;
        this.lastChapterName = lastChapterName;
        this.summary = summary;
        this.lastChapterid = lastChapterid;
        this.isRecommend = isRecommend;
        this.lastChapterNumber = lastChapterNumber;
        this.readSchedule = readSchedule;
        this.updateChapterNum = updateChapterNum;
        this.lastReadTime = lastReadTime;
        this.categoryNames = categoryNames;
        this.isVip = isVip;
        this.uuid = uuid;
        this.inBookself = inBookself;
        this.inDownLoad = inDownLoad;
        this.inReadRecord = inReadRecord;
        this.ext = ext;
        this.orderTime = orderTime;
    }

    @Generated(hash = 687480960)
    public BookData() {
    }


    public void setNovelid(String novelid) {
        this.novelid = novelid;
    }

    public String getNovelid() {
        return novelid;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getCover() {
        return cover;
    }

    public void setNovelName(String novelName) {
        this.novelName = novelName;
    }

    public String getNovelName() {
        return novelName;
    }

    public void setAuthorName(String authorName) {
        this.authorName = authorName;
    }

    public String getAuthorName() {
        return authorName;
    }

    public int getPromotionType() {
        return promotionType;
    }

    public void setIsComplete(int isComplete) {
        this.isComplete = isComplete;
    }

    public int getIsComplete() {
        return isComplete;
    }

    public void setLastChapterTitle(String lastChapterTitle) {
        this.lastChapterTitle = lastChapterTitle;
    }

    public String getLastChapterTitle() {
        return lastChapterTitle;
    }

    public void setLastChapterNumber(int lastChapterNumber) {
        this.lastChapterNumber = lastChapterNumber;
    }

    public int getLastChapterNumber() {
        return lastChapterNumber;
    }

    public void setUpdateChapterNum(int updateChapterNum) {
        this.updateChapterNum = updateChapterNum;
    }

    public int getUpdateChapterNum() {
        return updateChapterNum;
    }

    public void setLastReadTime(String lastReadTime) {
        this.lastReadTime = lastReadTime;
    }

    public String getLastReadTime() {
        if (lastReadTime == null) {
            return "0";
        }
        return lastReadTime;
    }

    public String getLastChapterName() {
        return lastChapterName;
    }

    public String getSummary() {
        return summary;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        BookData mdata = (BookData) obj;
        if (mdata.getNovelid() == null) {
            return mdata.getAd() == ad;
        }

        return mdata.getNovelid().equals(novelid);
    }

    public void setPromotionType(int promotionType) {
        this.promotionType = promotionType;
    }

    public void setLastChapterName(String lastChapterName) {
        this.lastChapterName = lastChapterName;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public String getUuid() {
        return this.uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }


    public int getInBookself() {
        return this.inBookself;
    }


    public void setInBookself(int inBookself) {
        this.inBookself = inBookself;
    }


    public int getInDownLoad() {
        return this.inDownLoad;
    }


    public void setInDownLoad(int inDownLoad) {
        this.inDownLoad = inDownLoad;
    }


    public int getInReadRecord() {
        return this.inReadRecord;
    }


    public void setInReadRecord(int inReadRecord) {
        this.inReadRecord = inReadRecord;
    }


    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getModuleid() {
        return moduleid;
    }

    public void setModuleid(String moduleid) {
        this.moduleid = moduleid;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getShowType() {
        return showType;
    }

    public void setShowType(int showType) {
        this.showType = showType;
    }

    public int getIsShowMore() {
        return isShowMore;
    }

    public void setIsShowMore(int isShowMore) {
        this.isShowMore = isShowMore;
    }

    public int getModulePromotionType() {
        return modulePromotionType;
    }

    public void setModulePromotionType(int modulePromotionType) {
        this.modulePromotionType = modulePromotionType;
    }

    public BookExtData getExt() {
        return ext;
    }

    public void setExt(BookExtData ext) {
        this.ext = ext;
    }

    public int getmType() {
        return mType;
    }

    public void setmType(int mType) {
        this.mType = mType;
    }


    public List<BookClassData> getCategoryNames() {
        return this.categoryNames;
    }


    public void setCategoryNames(List<BookClassData> categoryNames) {
        this.categoryNames = categoryNames;
    }


    public int getIsVip() {
        return this.isVip;
    }


    public void setIsVip(int isVip) {
        this.isVip = isVip;
    }

    public String getLastChapterid() {
        return this.lastChapterid;
    }

    public void setLastChapterid(String lastChapterid) {
        this.lastChapterid = lastChapterid;
    }

    /**
     * 是否系统推荐。1是，0否
     *
     * @return
     */
    public int getIsRecommend() {
        return this.isRecommend;
    }

    public void setIsRecommend(int isRecommend) {
        this.isRecommend = isRecommend;
    }

    public long getOrderTime() {
        return this.orderTime;
    }

    public void setOrderTime(long orderTime) {
        this.orderTime = orderTime;
    }

//    @NonNull
//    @Override
//    public String toString() {
//        return "inBookself=" + inBookself + "------" + "inDownLoad=" + inDownLoad + "-------inReadRecord=" + inReadRecord;
//    }

    @NonNull
    @Override
    public String toString() {
        return "addata=  " + getAd() + "  ------" + "novelid=" + novelid ;
    }

    public TTNativeExpressAd getAd() {
        return ad;
    }

    public void setAd(TTNativeExpressAd ad) {
        this.ad = ad;
    }

    public String getRankInfo() {
        return rankInfo;
    }

    public void setRankInfo(String rankInfo) {
        this.rankInfo = rankInfo;
    }

    public String getAuthorid() {
        return this.authorid;
    }

    public void setAuthorid(String authorid) {
        this.authorid = authorid;
    }

    public String getReadSchedule() {
        return this.readSchedule;
    }

    public void setReadSchedule(String readSchedule) {
        this.readSchedule = readSchedule;
    }

    public String getTips() {
        return tips;
    }

    public void setTips(String tips) {
        this.tips = tips;
    }

    public String getChapterTitle() {
        return chapterTitle;
    }

    public void setChapterTitle(String chapterTitle) {
        this.chapterTitle = chapterTitle;
    }

    public String getChapterid() {
        return chapterid;
    }

    public void setChapterid(String chapterid) {
        this.chapterid = chapterid;
    }

    public String getHotInfo() {
        return hotInfo;
    }

    public void setHotInfo(String hotInfo) {
        this.hotInfo = hotInfo;
    }

    public String getCollectInfo() {
        return collectInfo;
    }

    public void setCollectInfo(String collectInfo) {
        this.collectInfo = collectInfo;
    }

    public String getReadInfo() {
        return readInfo;
    }

    public void setReadInfo(String readInfo) {
        this.readInfo = readInfo;
    }
}
